/**
 * A Tower figure. extends figure.
 * This class represent any Tower figure.
 * every tower figure in the game will extend this class.
 * @authors Itay Sorani, Nadav Ziv, Yonathan Zarsky
 */
package com.example.models;

import android.content.Context;

import com.example.util.Figure;
import com.example.util.FigureType;

public abstract class Tower extends Figure {
	
	// the tower id
	private int towerId;
	// the tower damage
	private int damage;
	// the tower range
	private int range;
	//the tower fire rate
	private int rate;
	//the tower cost
	private int cost;
	//determines whether the tower can shoot according to its fire rate 
	private boolean canShoot; 
	// time left till next shot
	private int timeLeftTillRateReset;
	// the tower name
	private String name = "DeafultTowerName";
	// the shot type of this tower
	private String shotName;
	private float shotVelocity;
	
	/**
     * Constructs a new tower.
     */
	public Tower(Context context) {
		super(context);
		this.setCanShoot(true);
		setFigureType(FigureType.tower);
	}
	
	/**
     * Constructs a new tower.
     */
	public Tower() {
		super();
		setFigureType(FigureType.tower);
	}
	
	/**
     * sets the tower damage
     */
	public void setDamage(int damage) {
		this.damage = damage;
	}
	
	/**
     * abstract class.
     * returns the tower damage according to the tower type, and the given unit.
     */
	public abstract int getDamage(Unit unit); 
	
	/**
     * sets the tower range
     */
	public void setRange(int range) {
		this.range = range;
	}
	
	/**
     * returns the tower range
     */
	public int getRange() {
		return range;
	}
	
	/**
     * sets the tower fire rate
     */
	public void setRate(int rate) {
		this.rate = rate;
	}
	
	/**
     * returns the tower fire rate
     */
	public int getRate() {
		return rate;
	}
	
	/**
     * sets the tower cost
     */
	public void setCost(int cost) {
		this.cost = cost;
	}
	
	/**
     * returns the tower cost
     */
	public int getCost() {
		return cost;
	}

	/**
     * sets the tower id
     */
	public void setTowerId(int towerId) {
		this.towerId = towerId;
	}
	
	/**
     * returns the tower id
     */
	public int getTowerId() {
		return towerId;
	}

	/**
     * change the canShoot state.
     */
	public void setCanShoot(boolean canShoot) {
		this.canShoot = canShoot;
	}

	/**
     * returns the canShoot state.
     */
	public boolean CanShoot() {
		return canShoot;
	}
	
	/**
     * updates the shooting rate, and determines time till next shot.
     */
	public void updateShootingRate () {
		if (timeLeftTillRateReset <= 0){
			timeLeftTillRateReset = rate;
			canShoot = true;
		} else {
			timeLeftTillRateReset--;
		}
	}

	/**
     * sets the tower name
     */
	public void setName(String name) {
		this.name = name;
	}

	/**
     * returns the tower name
     */
	public String getName() {
		return name;
	}

	public void setShotName(String shotName) {
		this.shotName = shotName;
	}

	public String getShotName() {
		return shotName;
	}

	public void setShotVelocity(float shotVelocity) {
		this.shotVelocity = shotVelocity;
	}

	public float getShotVelocity() {
		return shotVelocity;
	}
	
}
